#!/usr/bin/env node

const jsdom = require('jsdom');
const { JSDOM } = jsdom;

const filepath = process.argv[2];

JSDOM.fromFile(filepath).then(dom => {
    const document = dom.window.document;
    //获取被替换的节点
    const oldDiv = document.getElementsByClassName('con')[0];
    //创建替换的节点
    const newP = document.createElement('p');
    newP.className = 'list';
    newP.innerHTML = oldDiv.innerHTML;
    //替换
    document.body.replaceChild(newP,oldDiv);
    //控制台打印输出替换后的html代码
    console.log(dom.serialize());
});

